// 并发聊天室客户端

package main

import (
	"fmt"
	"net"
)

func main() {
	con, err := net.Dial("tcp","localhost:8081")
	if err != nil {
		fmt.Println("报错：",err)
		return
	}
	defer con.Close()
	var msg []byte = make([]byte, 1024)
	go func() {
		var info string
		for true {
			_, err := fmt.Scanln(&info)
			if err != nil {
				fmt.Println("报错：", err)
				return
			}
			con.Write([]byte(info))
		}
	}()
	for true {
		num, RErr := con.Read(msg)
		if RErr != nil {
			fmt.Println("出错",err)
			return
		}
		fmt.Println(string(msg[0:num]))
	}
}
